Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(integ-tests): allow for user provided assertions stack #22404

Merged
merged 5 commits into from
Oct 10, 2022

Conversation

dontirun
Copy link
Contributor

@dontirun dontirun commented Oct 6, 2022

Closes #22332


All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use yarn integ to deploy the infrastructure and generate the snapshot (i.e. yarn integ without --dry-run)?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Oct 6, 2022

@github-actions github-actions bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK labels Oct 6, 2022
@aws-cdk-automation aws-cdk-automation requested a review from a team October 6, 2022 21:52
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

@dontirun
Copy link
Contributor Author

dontirun commented Oct 6, 2022

❌ Features must contain a change to an integration test file and the resulting snapshot.

Is that even possible in this case 😀?

@corymhall corymhall added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Oct 7, 2022
@aws-cdk-automation aws-cdk-automation dismissed their stale review October 7, 2022 13:01

✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.

Copy link
Contributor

@corymhall corymhall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dontirun thanks for picking this up!

super(scope, 'Default');

this.scope = new Stack(scope, 'DeployAssert');
this.scope = new Stack(scope, 'DeployAssert', { env: props?.env });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be better to actually allow the user to pass their own Stack. I think that is
what I originally intended to do. That also opens up the posibility to put the assertions in the
same Stack as your test stack.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that a lot more! Let me refactor this PR

I also think it's beneficial in the case the user wanting to keep the stacks separated. It allows for creating lambda functions for the Lambda assertions independent from what is being integration tested

@mergify mergify bot dismissed corymhall’s stale review October 7, 2022 15:46

Pull request has been modified.

@dontirun dontirun changed the title feat(integ-tests): environment aware assertions feat(integ-tests): allow for user provided assertions stack Oct 7, 2022
@dontirun
Copy link
Contributor Author

dontirun commented Oct 7, 2022

Hmm, this needs some more changes...

  test('Circular structure error', () => {
    //GIVEN
    const app = new App();
    const assertionsStack = new Stack(app, 'AssertionsStack');

    //WHEN
    const integ = new IntegTest(app, 'integ', {
      testCases: [],
      assertionsStack: assertionsStack,
    });

    // THEN
    Template.fromStack(assertionsStack);
  });
    TypeError: Converting circular structure to JSON
        --> starting at object with constructor 'Stack'
        |     property 'node' -> object with constructor 'Node'
        --- property 'host' closes the circle
        at JSON.stringify (<anonymous>)

      178 |       withVersion = preprocess(withVersion);
      179 |     }
    > 180 |     fs.writeFileSync(filePath, JSON.stringify(withVersion, undefined, 2));
          |                                     ^
      181 |   }
      182 |
      183 |   private static loadManifest(filePath: string, schema: jsonschema.Schema, preprocess?: (obj: any) => any, options?: LoadManifestOptions) {

      at Function.saveManifest (../cloud-assembly-schema/lib/manifest.ts:180:37)
      at Function.saveIntegManifest (../cloud-assembly-schema/lib/manifest.ts:102:14)
      at Function.write (lib/manifest-writer.ts:9:14)
      at IntegManifestSynthesizer.synthesize (lib/manifest-synthesizer.ts:24:25)
      at Object.onSynthesize (lib/test-case.ts:183:25)
      at cb (../core/lib/private/synthesis.ts:188:15)
      at visit (../core/lib/private/synthesis.ts:230:5)
      at visit (../core/lib/private/synthesis.ts:226:5)
      at synthesizeTree (../core/lib/private/synthesis.ts:175:3)

@dontirun
Copy link
Contributor Author

dontirun commented Oct 7, 2022

It was because of this line and generating the manifest. I got around this by just changing the property name from assertionsStack to assertionStack.

@mergify
Copy link
Contributor

mergify bot commented Oct 10, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 96faff8
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 39089f5 into aws:main Oct 10, 2022
@mergify
Copy link
Contributor

mergify bot commented Oct 10, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(integ-tests): Set environment for Deploy Assert Stack
3 participants